//$  工厂
function $(a){
//	alert(this);
	var char = a.substr(0,1);
	var b = a.substr(1);
	switch (char){
		case '#':
			return document.getElementById(b);
			break;
		case '.':
			return document.getElementsByClassName(b);
			break;
		default:
			return document.getElemtntsByTagName(a);
			break;
	}	
}

//   css
HTMLElement.prototype.css = function(k,v){
	k == 'cssText' ? this.style[k] += v : this.style[k] = v ;
}

//html 
HTMLElement.prototype.html = function(a){
	return (a == undefined) ? this.innerHTML : this.innerHTML = a ;  
}

// on  addEventListener
HTMLElement.prototype.on = function(a,fun,b){
	b = b || false;
	return this.addEventListener(a,fun,b);
}

//是否显示
HTMLElement.prototype.display = function(a){
	a =  a || false;
	return a ?  this.css('display','none') : this.css('display','block');
}



//存放所有图片
/*imgAll = ['5de0c8b12ad3cc1a641c5057.png','5de0c78a2ad3cc7a6a765f06.png','5de0ca122ad3cc7b9011482d.png',
'5de0cb4d2ad3cc7a65421322.png','5de5d9292ad3cc59f7619f75.png','5de08a6d2ad3cc584b0ee9fc.png',
'5de08a992ad3cc1a641c5021.png','5de33b4b2ad3cc7b885d5928.png','5de33f472ad3cc7ba0753a70.png','5de37fad2ad3cc7b8e6748ec.png',
'5de38f902ad3cc57a70438ed.png','5de61ada2ad3cc59fd447a83.png','5de62bd42ad3cc32d405949d.png','5de77e0c2ad3cc5a077c3a54.jpg',
'5de86ddc2ad3cc5a0d71ac74.jpg','5de334f52ad3cc1a992e7fb1.png','5de334f72ad3cc7a69394d4b.png','5de337ce2ad3cc1a6207e11b.png',
'5de337ce2ad3cc7b934f5717.png','5de624dd2ad3cc32c7355b0f.png',
'5de860f72ad3cc59fd447d56.jpg','5de3330c2ad3cc7b9c37d303.png','5de3737f2ad3cc04f671ddb8.png','5de4948b2ad3cc7ba71eabee.jpg',
'5de8775b2ad3cc5a0d71ac7e.jpg','5de339972ad3cc1a641c511b.png','5de874512ad3cc33167d37a9.jpg','5de879012ad3cc32e53700fb.jpg',
'5de890262ad3cc330f661198.jpg','5de892872ad3cc32d40597e8.jpg','5ded9fe02ad3cc06a5294bb5.png',
'download.png','tranl.png'
];

var loadPage = function(){
	this.imgs = imgAll;
	this.imgLen = this.imgs.length;
	this.loaded = 0; //以加载的图片数
	this.loadnum = 0;//加载进度
	var that = this;
	this.start = function(a){
		for(var i=0;i<that.imgLen;i++){
			var imga = new Image();
			imga.src = './img/'+that.imgs[i];
				// console.dir(imga.src);
			imga.onload = function(e){
				that.loaded++;
				that.loadnum = parseInt((that.loaded/that.imgLen)*100);
				a.html(that.loadnum+'%');
				if(that.loadnum == 100){
					loadOK();
				}
			}
		}		
	}
	
}
*/

//加载完成后执行的函数
function loadComple(){
	console.dir('加载页加载完成');
	fadeiInOut('#pg2','#pg1');
}

//两个页面淡入淡出切换

function fadeiInOut(a,b){
	fadeOut(b,fadeIn(a,''));
}

function fadeIn(el,fun){
	$(el).css('cssText','position:absolute;display:block;z-index:5;transition:.7s;opacity:.5;');
	setTimeout(function(){
		$(el).css('cssText','opacity:1');
	},80);
	$(el).on('transitionend',function(fun){
		fun;
	})
}
function fadeOut(el,fun){
	$(el).css('cssText','z-index:1;opacity:1;transition:.7s;');
	setTimeout(function(){
		$(el).css('cssText','opacity:0;');
	},50);
	$(el).on('transitionend',function(fun){
		$(el).display(1);
		fun;
	})
}